<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>USDT提现记录</title>
    <link rel="stylesheet" href="/layui-2.4.2/src/css/layui.css">
    <script type="text/javascript" src="/jquery/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="/layui-2.4.2/src/layui.js"></script>
</head>
<body>
<div>
    <div class="layui-row">
        <div class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">手机号:</label>
                <div class="layui-input-inline">
                    <input type="text" id="mobile" name="mobile" required lay-verify="required"
                           placeholder="请输入手机号"
                           autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label">账户id:</label>
                <div class="layui-input-inline">
                    <input type="text" id="accountId" name="accountId" required lay-verify="required"
                           placeholder="请输入账户id"
                           autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label">审核状态:</label>
                <div class="layui-input-inline">
                    <select name="status" class="status"
                            lay-filter="status_select">
                        <option value="">全部</option>
                        <option value="0">待审核</option>
                        <option value="1">提现中</option>
                        <option value="2">成功</option>
                        <option value="3">失败</option>
                    </select>
                </div>

            </div>
            <div class="layui-form-item">
                <button class="layui-btn" id="search">搜索</button>
            </div>


        </div>
    </div>

</div>
<div class="layui-row">
    <table id="user_list_view" lay-filter="user_filter">

    </table>
</div>
<form class="layui-form" id="order_detail" action="" style=" display:none;margin-left: 3%;margin-right: 3%">
    <div class="layui-form-item">
        <table id="usdt_order_detail_view" lay-filter="usdt_order_filter">

        </table>
    </div>
</form>
<form class="layui-form" id="user_order_detail" action="" style=" display:none;margin-left: 3%;margin-right: 3%">
    <div class="layui-form-item">
        <table id="usdt_user_order_detail_view" lay-filter="usdt_order_filter">

        </table>
    </div>
</form>
</body>
<form class="layui-form" id="edit_remark" action="" style="display:none;margin-top: 30px;">
    <div class="layui-form-item">
        <label class="layui-form-label">拒绝原因</label>
        <div class="layui-input-block" style="margin-right: 20px;">
            <input type="text" name="remark" id="remark" required  lay-verify="required" placeholder="请输入拒绝原因" class="layui-input">
        </div>
    </div>
</form>
<!--表格toobar模板-->
<script type="text/html" id="toolOper">
    {{#  if(d.status == 0 ){ }}
    <a class="layui-btn layui-btn-xs" lay-event="agree">同意</a>
    <a class="layui-btn layui-btn-xs" lay-event="refuse">拒绝</a>
    {{#  } }}
    {{#  if(d.status > 0){ }}
    <a class="layui-btn layui-btn-xs" lay-event="details">详情</a>
    {{#  } }}
    <a class="layui-btn layui-btn-xs" lay-event="record">查看记录</a>
</script>

<script>
    layui.use(['element', 'table', 'upload', 'laytpl', 'form'], function () {
        var table = layui.table;
        table.render({
            elem: '#user_list_view',
            url: '/usdtLog/queryList',
            page: true,
            size: 10,
            limits: [10, 20, 50, 100],
            cols: [
                [
                    {field: 'orderNo', title: '订单号'},
                    {field: 'accountId', title: '用户id'},
                    {field: 'nickName', title: '昵称'},
                    {field: 'mobile', title: '手机号'},
                    {field: 'usdtValue', width:140, title: '提现金额(USDT)'},
                    {field: 'usdtFees', width:140, title: '手续费(USDT)'},
                    {field: 'currentRate', title: '兑换汇率'},
                    {field: 'usdValue',  width:140, title: '提现金额(USD)'},
                    {field: 'createTime', title: '申请时间'},
                    {
                        field: 'status',  title: '审核状态', templet: function (d) {
                            if (d.status === 0) return '待审核';
                            if (d.status === 1) return '提现中';
                            if (d.status === 2) return '成功';
                            if (d.status === 3) return '失败';
                            if (d.status === 4) return '提现失败,请联系管理员';
                        }
                    },
                    {field: 'reason', title: '拒绝原因'},
                    {field: 'right', width: 300, align: 'center', toolbar: '#toolOper',title:'操作'}
                ]
            ],
            response: {
                status: 'errorCode',
                countName: 'total',
                dataName: 'data'
            }
        });


        $("#search").on('click', function () {
            table.reload('user_list_view', {
                url: '/usdtLog/queryList',
                where: {
                    mobile: $('#mobile').val(),
                    status: $('.status').val(),
                    accountId: $('#user_account_input').val()
                }
            });
        });



        table.on('tool(user_filter)', function (obj) {
            var data = obj.data;
            var layEvent = obj.event;
            var id = data.id;
            //查看记录
            if (layEvent == 'record'){
                layer.open({
                    type: 1,
                    skin: 'layui-layer-demo', //样式类名
                    closeBtn: false, //不显示关闭按钮
                    anim: 2,
                    shadeClose: true, //开启遮罩关闭
                    area: ['80%', '70%'],
                    title: "订单详情",
                    content: $("#user_order_detail")
//                    content:"内容"
                });
                table.render({
                    elem: '#usdt_user_order_detail_view',
                    url: '/usdtLog/queryUsdtBill?sessionId=' + data.sessionId,
                    page: true,
                    size: 10,
                    limits: [10, 20, 50, 100],
                    cols: [
                        [
                            {field: 'usdtValue', title: '金额'},
                            {field: 'remark', title: '类型'},
                            {field: 'updateTime', title: '时间'}
                        ]
                    ],
                    response: {
                        status: 'errorCode',
                        countName: 'total',
                        dataName: 'data'
                    }
                });
            }
            //查看详情
            if (layEvent == 'details'){
                    layer.open({
                        type: 1,
                        skin: 'layui-layer-demo', //样式类名
                        closeBtn: false, //不显示关闭按钮
                        anim: 2,
                        shadeClose: true, //开启遮罩关闭
                        area: ['90%', '80%'],
                        title: "订单详情",
                        content: $("#order_detail")
//                    content:"内容"
                    });
                    table.render({
                        elem: '#usdt_order_detail_view',
                        url: '/usdtLog/queryList?orderNo=' + data.orderNo,
                        page: false,
                        cols: [
                            [
                                {field: 'orderNo', title: '订单号'},
                                {field: 'accountId', title: '用户id'},
                                {field: 'nickName', title: '昵称'},
                                {field: 'mobile', title: '手机号'},
                                {field: 'usdtValue', width:140, title: '提现金额(USDT)'},
                                {field: 'usdtFees', width:140, title: '手续费(USDT)'},
                                {field: 'currentRate', title: '兑换汇率'},
                                {field: 'usdValue', width:140, title: '提现金额(USD)'},
                                {field: 'createUser', title: '审核人'},
                                {field: 'createTime', title: '申请时间'},
                                {field: 'checkTime', title: '审核时间'},
                                {field: 'reason', title: '拒绝原因'},
                                {field: 'remark', title: '备注'}
                            ]
                        ],
                        response: {
                            status: 'errorCode',
                            countName: 'total',
                            dataName: 'data'
                        }
                    });
            }
            if (layEvent == 'agree') {
                if (window.confirm('请确认是否将' + data.accountId + '的提现申请审核通过')) {
                    if (layEvent === 'agree') {
                        //同意。状态改为提现中
                        var data = {'status': 1, id: id};
                        $.ajax({
                            type: 'get',
                            data: data,
                            url: '/usdtLog/updateStatus',
                            cache: false,
                            success: function (data) {
                                if (data.success == true) {
                                    alert("审核成功");
                                } else {
                                    alert(data.msg);
                                }
                                $(".layui-laypage-btn").click();
                            },

                        });
                    }
                }
            }
            if (layEvent==='refuse') {
                layer.open({
                    type: 1,
                    area: ['300px', '200px'],
                    content: $("#edit_remark"),
                    btn: ['保存', '取消'],
                    btnALign: 'c',
                    yes: function (index, layero) {
                        if ($("#remark").val() == '') {
                            alert('请输入拒绝原因');
                            return;
                        }
                        //拒绝。状态改为失败
                        var data = {'id':id,'remark':$("#remark").val(),'status':3};
                        $.ajax({
                            type: 'get',
                            data:data ,
                            url: '/usdtLog/updateStatus',
                            cache: false,
                            dataType: 'json',
                            success: function (data) {
                                if (data.success == true) {
                                    alert("审核成功");
                                } else {
                                    alert(data.msg);
                                }
                                layer.closeAll();
                                $(".layui-laypage-btn").click()
                            }
                        });
                    },
                });
            }
        });

    });

</script>

</html>